package com.etc.util;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

public class CommonRpc {
   /**
    * cyf
    * 通过调用接口实现的发送短信验证码的方法
    * @param num 用户收到的验证码
    */
	public static void sendMassage(String phone,int num) {
        DefaultProfile profile = DefaultProfile.getProfile("default","LTAI122vlcPy0GhM","Tv88EhqNnihuJUxQJ61iDBDXiCjuhj");
        IAcsClient client = new DefaultAcsClient(profile);
        CommonRequest request = new CommonRequest();
        request.setMethod(MethodType.POST);
        request.setDomain("dysmsapi.aliyuncs.com");
        request.setVersion("2017-05-25");
        request.setAction("SendSms");
        request.putQueryParameter("PhoneNumbers", ""+phone+"");
        request.putQueryParameter("SignName", "微网盘");
        request.putQueryParameter("TemplateCode", "SMS_165413960");
        request.putQueryParameter("TemplateParam", "{\"code\":\""+num+"\"}");
        try {
            CommonResponse response = client.getCommonResponse(request);
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
  
	}
    
  
}